/*
 * LtiCam.cpp
 *
 *  Created on: May 29, 2009
 *      Author: flaviotruzzi
 */


#include <cxcore.h>
#include "LtiCam.h"
#include <iostream>

LtiCam::LtiCam(int number) {
	_camera = cvCaptureFromCAM(number);

    if (!_camera)
         throw -1;

    frame = cvQueryFrame(_camera);
    workimg = cvCreateImage(cvGetSize(frame), 8, 3);
    cvCopy(frame,workimg,NULL);

}

LtiCam::LtiCam(char *name) {
	_camera = cvCaptureFromFile(name);

	if (!_camera)
		throw -1;

	frame = cvQueryFrame(_camera);

}

LtiCam::~LtiCam() {
    cvReleaseCapture(&_camera);
}

void LtiCam::Read() {
    frame = cvQueryFrame(_camera);
    if (frame)
    	cvCopy(frame,workimg,NULL);
}
